﻿using Aliyun.OSS;
using Microsoft.AspNetCore.Mvc;
using store.cyt369.com.MODELS;

namespace store.cyt369.com.Controllers
{
    public class StoreController : Controller
    {
        public IActionResult Index(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                var argsJson = Base64.Base64ToJSON(id);
                long? brandId = argsJson.GetInteger("id");
                if (brandId.HasValue)
                {
                    var storeDetail = store.cyt369.com.dal.StoreService.Instance.GetStoreByID(brandId.Value);
                    var citys = store.cyt369.com.dal.CityService.Instance.GetCitys();
                    ViewBag.propertyEquipments = store.cyt369.com.dal.PropertyEquipmentService.Instance.GetPropertyEquipments();
                    ViewBag.storePropertyEquipments = store.cyt369.com.dal.StoreService.Instance.GetStorePropertyEquipment(storeDetail.Id);
                    ViewBag.storeDetail = storeDetail;
                    ViewBag.citys = citys;

                    return View();
                }
                return Ok();
            }
            else
            {
                return Ok();
            }

        }
        [HttpGet]
        public IActionResult GetStoreExtension(int storeId)
        {
            var storeExtension = store.cyt369.com.dal.StoreService.Instance.GetStoreExtension(storeId);
            return Json(storeExtension);
        }
    }
}
